<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="../../include/admincontent.jsp" %>
<div id="location">当前位置：首页 > 系统信息管理 > 黑名单管理</div>
<div id="Content">
</div>
<div id="sy_search" class=" f0f0f0" style="display: inline-block">
    <form id="advanceQueryParam">
        <div style="background-color: #f0f0f0">
            <div class="clearfix more_query_area">
                <div class="query_area_body clearfix">
                    <div class="record_item">
                        <div class="record_item">
                            <div class="label">身份证号:</div>
                            <div class="content">
                                <div><input type="text" name="ucode"/></div>
                            </div>
                        </div>
                    </div>
                    <div class="record_item">
                        <div class="record_item">
                            <div class="label">真实姓名:</div>
                            <div class="content">
                                <div><input type="text" name="uname"/></div>
                            </div>
                        </div>
                    </div>
                    <div class="record_item">
                        <div class="record_item">
                            <div class="label width100">是否创建简历:</div>
                            <div class="content">
                                <div>
                                    <select name="hasresume">
                                        <option value="-1">全部</option>
                                        <option value="0">是</option>
                                        <option value="1">否</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="record_item">
                        <div class="toolbars">
                            <a id="searchbtn">
                                <em class="ico16 search_16"></em>
                                <span class="menu_span" title="查询">查询</span>
                            </a>
                            <a id="searchreset">
                                <em class="ico16 refresh_16"></em>
                                <span class="menu_span" title="重置">重置</span>
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <%--<a width="60" id="combineQuery" class="font_size12 common_button combinedQuery">查询</a>--%>
</div>
<div style="overflow:hidden;">
    <div id="div_table" style="bottom: 0px">
        <table class="layui-hide" id="table" lay-filter="memberBlacklistTable"></table>
    </div>
</div>

<script type="text/html" id="toolbartemplate">
    <a class="layui-btn layui-btn-xs" lay-event="remove">移除黑名单</a>
</script>
<script type="text/javascript">
    $(document).ready(function () {
        $(document).ready(function () {
            layui.use('table', () => {
                let table = layui.table;
                table.render({
                    id: 'table'
                    , elem: '#table'
                    , height: 'full'
                    , url: '/member/getblacksLayuiJson' //数据接口
                    , title: '用户表'
                    , page: true //开启分页
                    , method: 'post'
                    , cols: [[ //表头
                        {type: 'numbers', title: '序号', fixed: 'left', width: '5%', sort: true}
                        , {field: 'uname', title: '姓名', width: '5%', sort: true, templet: profile}
                        , {field: 'ucode', title: '身份证号', width: '15%', sort: true}
                        , {field: 'uemail', title: '邮箱', width: '15%', sort: true}
                        , {field: 'regtimeS', title: '注册时间', width: '10%', sort: true}
                        , {field: 'blacktime', title: '加入黑名单时间', width: '10%', sort: true}
                        , {field: 'blackreason', title: '加入黑名单原因', width: '30%'}
                        , {toolbar: '#toolbartemplate', title: '操作', fixed: 'right', width: '10%'}
                    ]]
                    , where: {
                        ucode: $("input[name='ucode']").val(),
                        uname: $("input[name='uname']").val(),
                        hasresume: $("select[name='hasresume']").val(),
                        ustate: $("select[name='ustate']").val(),
                    },
                    text: {
                        none: '暂无黑名单用户',
                    }
                });

                function profile(d) {
                    if (d.hasresumeS === "是") {
                        return "<a target='_blank' href='/Do/SZResume/ViewResumeCardno?cardno=" + d.ucode + "'>" + d.uname + "</a>";
                    } else {
                        return d.uname;
                    }
                }

                $("#searchbtn").on('click', () => {
                    table.reload('table', {
                        where: {
                            ucode: $("input[name='ucode']").val(),
                            uname: $("input[name='uname']").val(),
                            hasresume: $("select[name='hasresume']").val(),
                            ustate: $("select[name='ustate']").val(),
                        }, page: {
                            curr: 1
                        }
                        , done: (res, curr, count) => {
                            tableresize(diff, false)
                        }
                    })
                });
                reload = () => {
                    table.reload('table');
                }
                document.tablereload = reload;
                table.on('tool(memberBlacklistTable)', (obj) => {
                    var data = obj.data; //获得当前行数据
                    var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
                    var tr = obj.tr; //获得当前行 tr 的 DOM 对象（如果有的话）
                    if (layEvent === 'remove') {
                        blackuser(data.id);
                    }
                });

            });

            //移除黑名单
            function blackuser(id) {
                postAjax('/member/OutBlackAction?id=' + id, null, function (data) {
                    if (data.state) {
                        reload();
                    }
                    $.Showmsg(data.Message);
                });
            }

            function tableresize(diff, resizeout = true) {
                let height3 = $("#div_table").height();
                let height4 = $(".layui-table-body.layui-table-main").height();
                let height5 = $(".layui-form.layui-border-box.layui-table-view").height();


                if (resizeout) {
                    $("#div_table").height(height3 - diff);
                }
                $(".layui-table-body.layui-table-main").height(height4 - diff);
                $(".layui-form.layui-border-box.layui-table-view").height(height5 - diff);
            }

            let diff;
            let origin = {};
            $("#combineQuery").on('click', (e) => {


                let style = $("#advanceQueryParam")[0].style;
                if (style.display === 'block') {
                    style.display = 'none';
                    diff = -origin.diff;
                } else {
                    style.display = 'block';
                    if (!origin.diff) {
                        origin.diff = document.documentElement.scrollHeight - document.documentElement.clientHeight;
                    }
                    diff = origin.diff;
                }
                tableresize(diff);
            });
            $("#searchreset").on('click', (e) => {
                document.getElementById("advanceQueryParam").reset();
                $("input[name='deptcode']").val("")
            });
        });

    });


</script>
</body>
</html>